package com.fsoft.finaltest.controller;

import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.fsoft.finaltest.dao.AnimalJDBCTemplate;
import com.fsoft.finaltest.dto.Animal;

public class App {
   public static void main(String[] args) {
      ApplicationContext context = 
             new ClassPathXmlApplicationContext("Bean.xml");

      AnimalJDBCTemplate animalJDBCTemplate = 
      (AnimalJDBCTemplate)context.getBean("animalJDBCTemplate");
      
      System.out.println("------Records Creation--------" );
      //animalJDBCTemplate.create(8,"Blu", true);

      System.out.println("------Listing Multiple Records--------" );
      List<Animal> animals = animalJDBCTemplate.listAnimal();
      for (Animal record : animals) {
         System.out.print("ID : " + record.get_animalID() );
         System.out.print(", Name : " + record.get_animalName() );
         System.out.println(", IsHunrry : " + record.get_state());
      }

      //System.out.println("----Updating Record with ID = 2 -----" );
      //animalJDBCTemplate.update(1, "Blu", false);

      System.out.println("----Listing Record with ID = 2 -----" );
      Animal animal = animalJDBCTemplate.getAnimal(2);
      System.out.print("ID : " + animal.get_animalID() );
      System.out.print(", Name : " + animal.get_animalName() );
      System.out.println(", IsHunrry : " + animal.get_state());
	  
   }
}
